package com.itheima.d5_arrays;

import java.util.Arrays;
import java.util.Comparator;

public class ArraysTest2 {
    public static void main(String[] args) {
        Student s1 = new Student("张三", 23, 1.80);
        Student s2 = new Student("李四", 24, 1.75);
        Student s3 = new Student("王五", 25, 1.88);
        Student s4 = new Student("赵六", 26, 1.90);
        Arrays.sort(new Student[]{s1, s2, s3, s4});
        System.out.println(Arrays.toString(new Student[]{s1, s2, s3, s4}));

        /*Arrays.sort(new Student[]{s1, s2, s3, s4}, new Comparator<Student>() {
                    @Override
                    public int compare(Student o1, Student o2) {
                        return Double.compare(o1.getHeight(), o2.getHeight());
                    }
                });*/
        /*Arrays.sort(new Student[]{s1, s2, s3, s4}, (Student o1, Student o2) -> {
                return Double.compare(o1.getHeight(), o2.getHeight());
            }
        );*/
        //静态引用方法
        //Arrays.sort(new Student[]{s1,s2,s3,s4},CompareByData::comparebyAge);

        CompareByData compare = new CompareByData();
        Arrays.sort(new Student[]{s1,s2,s3,s4},compare::compareDecs);
        System.out.println(Arrays.toString(new Student[]{s1, s2, s3, s4}));
    }
}
